package com.xxwy.ddu.cms.authonrize.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author xxwy
 * @since 2018-08-14
 */
@Builder
@ToString
@TableName("bs_user")
public class BaseUser extends Model<BaseUser>  {

    private static final long serialVersionUID = 1L;

    @TableId(value = "u_id", type = IdType.AUTO)
    private Integer uId;

    @NotBlank
    private String uName;
    @NotBlank
    private String uPassword;

    @TableLogic
    @TableField(value = "delete_flag")
    private Integer deleteFlag;

    private Boolean isBlock;

    @JSONField(format="HH:mm:ss")
    private Date uCreatetime;

    private String phone;

    @TableField(exist =false)
    private List<Role> roles;

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Date getuCreatetime() {
        return uCreatetime;
    }

    public void setuCreatetime(Date uCreatetime) {
        this.uCreatetime = uCreatetime;
    }

    public List<Role> getRoles() {
        return roles;
    }


    public Boolean getBlock() {
        return isBlock;
    }

    public void setBlock(Boolean block) {
        isBlock = block;
    }

    public Integer getDeleteFlag() {
        return deleteFlag;
    }

    public void setDeleteFlag(Integer deleteFlag) {
        this.deleteFlag = deleteFlag;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }

    public Integer getuId() {
        return uId;
    }

    public void setuId(Integer uId) {
        this.uId = uId;
    }
    public String getuName() {
        return uName;
    }

    public void setuName(String uName) {
        this.uName = uName;
    }
    public String getuPassword() {
        return uPassword;
    }

    public void setuPassword(String uPassword) {
        this.uPassword = uPassword;
    }

    @Override
    protected Serializable pkVal() {
        return this.uId;
    }


    public BaseUser() {
    }

    public BaseUser(Integer uId, String uName, String uPassword, Integer deleteFlag, Boolean isBlock, Date uCreatetime, String phone, List<Role> roles) {
        this.uId = uId;
        this.uName = uName;
        this.uPassword = uPassword;
        this.deleteFlag = deleteFlag;
        this.isBlock = isBlock;
        this.uCreatetime = uCreatetime;
        this.phone = phone;
        this.roles = roles;
    }

    @Override
    public String toString() {
        return "BaseUser{" +
                "uId=" + uId +
                ", uName='" + uName + '\'' +
                ", uPassword='" + uPassword + '\'' +
                ", deleteFlag=" + deleteFlag +
                ", isBlock=" + isBlock +
                ", uCreatetime=" + uCreatetime +
                ", phone='" + phone + '\'' +
                ", roles=" + roles +
                '}';
    }
}
